//
// SingularityEvent.as - Common event manager for Singularity library.
//
// copyright (c) 2006-2007, Jim Armstrong.  All Rights Reserved.  
//
// This software program is supplied 'as is' without any warranty, express, implied, 
// or otherwise, including without limitation all warranties of merchantability or fitness
// for a particular purpose.  Jim Armstrong shall not be liable for any special incidental, or 
// consequential damages, including, without limitation, lost revenues, lost profits, or 
// loss of prospective economic advantage, resulting from the use or misuse of this software 
// program.
//
// programmed by Jim Armstrong, Singularity (www.algorithmist.net)
//
//

package singularity.events;

  import flash.events.Event;
  
  class SingularityEvent extends Event {
  	
  	public var classname(get, set) :String;
  	public var errType(get, null) :String    ;
  	public var message(null, set) :String;
  	public var methodname(get, set) :String;
  	public static var ERROR:String     = "E";
  	public static var WARNING:String   = "W";
  	public static var INIT:String      = "I";
  	public static var COMPLETE:String  = "C";
  	public static var ROLL_OVER:String = "OVR";
  	public static var ROLL_OUT:String  = "OUT";
  	public static var SELECTED:String  = "S";
  	public static var ID:String        = "ID";
  	
  	var __type:String;      // Event type
  	var __message:String;   // Message associated with event
  	var __class:String;     // Class name associated with this event
  	var __method:String;    // Method name associated with this event
  	
    public function new(_typ:String, ?_bubbles:Bool = false, ?_cancelable:Bool = false ){
      super(_typ, _bubbles, _cancelable);
      
      __type       = _typ;
      __message    = "";
      __class      = "";
      __method     = "";
    }
    
    public function get_classname():String{ return __class;  }
    public function get_methodname():String{ return __method; }
    public function get_errType():String    { return __type;   }
    
    public function set_classname(_s:String):String{
      if( _s != "" )
        __class = _s;
    	return _s;
     }
    
    public function set_methodname(_m:String):String{
      if( _m != "" )
        __method = _m;
    	return _m;
     }
    
    public function set_message(_m:String):String{
      if( _m != "" )
        __message = _m;
    	return _m;
     }
    
    public override function clone():Event
    {
      return new SingularityEvent(__type);
    }
    
    public override function toString():String 
    { 
      return "From:" + __class + "::" + __method + " , message:" + __message;
    }
  }
